package com.fy56.platform.goodsTracking.service.impl;

import com.dexcoder.dal.JdbcDao;
import com.fy56.platform.goodsTracking.model.GoodsPublic;
import com.fy56.platform.goodsTracking.model.GoodstrackedRecordPublic;
import com.fy56.platform.goodsTracking.model.GoodstrackedRecordTopPublic;
import com.fy56.platform.goodsTracking.service.GoodstrackedRecordPublicServie;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by XTK on 2016-11-28.
 */
@Repository
public class GoodstrackedRecordPublicImpl implements GoodstrackedRecordPublicServie {
    static Logger log = Logger.getLogger(GoodstrackedRecordPublicServie.class);
    @Autowired
    JdbcDao jdbcDao_GoodsTracked;

    @Override
    public List<GoodstrackedRecordPublic> selectByNotUpload_Police(String organizationcode, String beginTime, String endTime) {

        String sql = "select GoodsTracked_Record_Public.*,CONVERT(varchar(100), GoodsTracked_Record_Public.SysTime, 20) SYSTIME\n" +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillNumber \n" +
                ",GoodsTracked_Record_Top_Public.GoodsNumber\n" +
                ",GoodsTracked_Record_Top_Public.ManualNumber\n" +
                "from GoodsTracked_Record_Public WITH(NOLOCK) \n" +
                "left join GoodsTracked_Record_Top_Public WITH(NOLOCK) \n" +
                "on GoodsTracked_Record_Public.ConsignmentBillMasterId=GoodsTracked_Record_Top_Public.ConsignmentBillMasterId " +
                " where GoodsTracked_Record_Public.Systime<='" + endTime + "'" +
                " and  GoodsTracked_Record_Public.Systime>='" + beginTime + "'" +
                " and GoodsTracked_Record_Public.organizationcode='" + organizationcode + "'" +
              /*  " and (GoodsTracked_Record_Public.upload is null or GoodsTracked_Record_Public.upload is null)" +*/
                " order by GoodsTracked_Record_Public.systime";
        //System.out.print(sql);
        return jdbcDao_GoodsTracked.queryListForSql(sql, GoodstrackedRecordPublic.class);
    }

    @Override
    public List<GoodstrackedRecordPublic> selectByNotUpload(String organizationcode, String beginTime, String endTime) {

        String sql = "select GoodsTracked_Record_Public.*,CONVERT(varchar(100), GoodsTracked_Record_Public.SysTime, 20) SYSTIME\n" +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillNumber \n" +
                ",GoodsTracked_Record_Top_Public.GoodsNumber\n" +
                ",GoodsTracked_Record_Top_Public.ManualNumber\n" +
                "from GoodsTracked_Record_Public WITH(NOLOCK) \n" +
                "left join GoodsTracked_Record_Top_Public WITH(NOLOCK)  \n" +
                "on GoodsTracked_Record_Public.ConsignmentBillMasterId=GoodsTracked_Record_Top_Public.ConsignmentBillMasterId " +
                " where  GoodsTracked_Record_Top_Public.ConsignmentBillMasterId is not null " +
                " and GoodsTracked_Record_Public.Systime>='" + beginTime + "'" +
                " and GoodsTracked_Record_Public.Systime<='" + endTime + "'" +
                " and GoodsTracked_Record_Public.organizationcode='" + organizationcode + "'" +
                " and GoodsTracked_Record_Public.upload is null" +
                " order by GoodsTracked_Record_Public.systime";
        // System.out.print(sql);
        return jdbcDao_GoodsTracked.queryListForSql(sql, GoodstrackedRecordPublic.class);
    }

    @Override
    public void updateByupload(GoodstrackedRecordPublic sub) {
        jdbcDao_GoodsTracked.updateForSql("update GoodsTracked_Record_Public " +
                "set upload='" + sub.getUpload()
                + "',uploadError='"
                + sub.getUploaderror() + "' where Recordid=" + sub.getRecordid());
    }

    @Override
    public void updateTyCallback(String recordid,String consignmentbillmasterid,String code,String message){
        jdbcDao_GoodsTracked.updateForSql("update GoodsTracked_Record_Public " +
                "set tyCallbackCode='" + code
                + "',tyCallbackMessage='"
                + message + "' where recordid='" + recordid +"' and consignmentbillmasterid='"+ consignmentbillmasterid +"'");
    }

    @Override
    public void updateTop(String ConsignmentBillNumber,String tracePlatformId,String OrganizationCode,String id) {
        try {
            String sql ="update GoodsTracked_Record_Top_Public  " +
                    "set tracePlatformId='" + tracePlatformId + "',uploadFlag='1' where OrganizationCode='"+OrganizationCode+"' and ConsignmentBillMasterId='"+id+"'";
//            log.info(" updateTop sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
//            String sql2="update  GoodsTracked_Record_Public  " +
//                    "set tracePlatformId='" + tracePlatformId + "' where OrganizationCode='"+OrganizationCode+"' and ConsignmentBillMasterId='"+id+"'";
//            log.info(" updateTop sql:"+sql2);
//            jdbcDao_GoodsTracked.updateForSql(sql2 );
        }catch (Exception e){
            log.error(" updateTop error:",e);
        }

    }
    @Override
    public void updateTopNew(String ConsignmentBillNumber,String tracePlatformId,String OrganizationCode,String id) {
        try {
            String sql ="update GoodsTracked_Record_Top_Public  " +
                    "set  uploadFlag='1' where OrganizationCode='"+OrganizationCode+"' and ConsignmentBillMasterId='"+id+"'";
//            log.info(" updateTop sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
//            String sql2="update  GoodsTracked_Record_Public  " +
//                    "set tracePlatformId='" + tracePlatformId + "' where OrganizationCode='"+OrganizationCode+"' and ConsignmentBillMasterId='"+id+"'";
//            log.info(" updateTop sql:"+sql2);
//            jdbcDao_GoodsTracked.updateForSql(sql2 );
        }catch (Exception e){
            log.error(" updateTop error:",e);
        }

    }
    @Override
    public void updatePublic(String ConsignmentBillNumber,String tracePlatformId,String OrganizationCode,String id) {
        try {
            String sql ="update  GoodsTracked_Record_Public  " +
                    "set UNIQUE_NO='" + tracePlatformId + "'"+ " where " +
                    " OrganizationCode='"+OrganizationCode+"' " +
                    " and ConsignmentBillMasterId='"+ConsignmentBillNumber+"'"+
                    " and RecordID='"+id+"'" ;
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updatePublic error:",e);
        }

    }
    @Override
    public List<GoodstrackedRecordTopPublic> selNotUploadList(String organizationcode, String beginTime, String endTime) {

        String sql = "select CONVERT(varchar(100), GoodsTracked_Record_Top_Public.SysTime, 20) SYSTIME " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillNumber " +
                ",GoodsTracked_Record_Top_Public.GoodsNumber " +
                ",GoodsTracked_Record_Top_Public.ManualNumber,GoodsTracked_Record_Top_Public.* " +
                "from GoodsTracked_Record_Top_Public  " +
                " where  1=1 " +
                " and GoodsTracked_Record_Top_Public.Systime>='" + beginTime + "'" +
                " and GoodsTracked_Record_Top_Public.Systime<='" + endTime + "'" +
//                " and GoodsTracked_Record_Top_Public.organizationcode='" + organizationcode + "'" +
                " and (GoodsTracked_Record_Top_Public.TracePlatformId is null or GoodsTracked_Record_Top_Public.TracePlatformId='') " +
                " order by GoodsTracked_Record_Top_Public.systime asc ";
         System.out.print("selNotUploadList:"+sql);
         List<GoodstrackedRecordTopPublic> result = null;
        try{
            result = jdbcDao_GoodsTracked.queryListForSql(sql, GoodstrackedRecordTopPublic.class);
        }catch (Exception e){
            log.error("selNotUploadList:",e);
            System.out.print("selNotUploadList error:"+e);

        }
        return result;
    }
    @Override
    public List<GoodsPublic> selectByNotUpload_List(String organizationcode, String beginTime, String endTime) {

        String sql = "select  GoodsTracked_Record_Top_Public.databasename databasename, GoodsTracked_Record_Public.SYSTIME" +
        ",GoodsTracked_Record_Public.Createcompanyname createcompanyname  " +
                ",GoodsTracked_Record_Public.TypeNum  " +
                ",GoodsTracked_Record_Public.TypeName" +
                ",GoodsTracked_Record_Public.Info " +
                ",GoodsTracked_Record_Public.CreateOperator " +
                ",GoodsTracked_Record_Public.UNIQUE_NO " +
                ",GoodsTracked_Record_Public.RecordID " +
                ",GoodsTracked_Record_Public.Longitude " +
                ",GoodsTracked_Record_Public.Latitude " +
                ",GoodsTracked_Record_Public.DriverCode " +
                ",GoodsTracked_Record_Public.DriverName " +
                ",GoodsTracked_Record_Public.CarLicense " +
                ",GoodsTracked_Record_Top_Public.OrganizationCode " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillMasterId " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillNumber " +
                ",GoodsTracked_Record_Top_Public.GoodsNumber " +
                ",GoodsTracked_Record_Top_Public.ManualNumber " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillDate " +
                ",GoodsTracked_Record_Top_Public.PlaceOfLoading " +
                ",GoodsTracked_Record_Top_Public.SendCompany " +
                ",GoodsTracked_Record_Top_Public.ReceiveCompany " +
                ",GoodsTracked_Record_Top_Public.UnloadPlace " +
                ",GoodsTracked_Record_Top_Public.ConsignorCompanyCode " +
                ",GoodsTracked_Record_Top_Public.ConsignorCompany " +
                ",GoodsTracked_Record_Top_Public.Consignor " +
                ",GoodsTracked_Record_Top_Public.ConsignorMobileTelephone " +
                ",GoodsTracked_Record_Top_Public.ConsignorTelephone " +
                ",GoodsTracked_Record_Top_Public.ConsignorAddress " +
                ",GoodsTracked_Record_Top_Public.ConsigneeCompanyCode " +
                ",GoodsTracked_Record_Top_Public.ConsigneeCompany " +
                ",GoodsTracked_Record_Top_Public.Consignee " +
                ",GoodsTracked_Record_Top_Public.ConsigneeMobileTelephone " +
                ",GoodsTracked_Record_Top_Public.ConsigneeTelephone " +
                ",GoodsTracked_Record_Top_Public.ConsigneeAddress " +
                ",GoodsTracked_Record_Top_Public.OneCardCode " +
                ",GoodsTracked_Record_Top_Public.BankName " +
                ",GoodsTracked_Record_Top_Public.AccountHolder " +
                ",GoodsTracked_Record_Top_Public.Account " +
                ",GoodsTracked_Record_Top_Public.PaymentMethod " +
                ",GoodsTracked_Record_Top_Public.GoodsPickupMethod " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillRemark " +
                ",GoodsTracked_Record_Top_Public.GoodsName " +
                ",GoodsTracked_Record_Top_Public.GoodsPack " +
                ",GoodsTracked_Record_Top_Public.ReceiptNumber " +
                ",GoodsTracked_Record_Top_Public.IsReceipt " +
                ",GoodsTracked_Record_Top_Public.ReceiptCount " +
                ",GoodsTracked_Record_Top_Public.ReceiptRemark " +
                ",GoodsTracked_Record_Top_Public.TotalNumberOfPackages " +
                ",GoodsTracked_Record_Top_Public.TotalWeight " +
                ",GoodsTracked_Record_Top_Public.TotalVolume " +
                ",GoodsTracked_Record_Top_Public.TotalTransportCost " +
                ",GoodsTracked_Record_Top_Public.CollectionGoodsValue " +
                ",GoodsTracked_Record_Top_Public.AdvanceGoodsValue " +
                ",GoodsTracked_Record_Top_Public.AdvanceTransportCost " +
                ",GoodsTracked_Record_Top_Public.DataType " +
                ",GoodsTracked_Record_Top_Public.Consignoridcard " +
                ",GoodsTracked_Record_Top_Public.Consigneeidcard " +
                ",GoodsTracked_Record_Top_Public.Headquarterscode " +
                ",GoodsTracked_Record_Top_Public.Headquarterspassword " +
                ",GoodsTracked_Record_Top_Public.Consignmentcode " +
                ",GoodsTracked_Record_Top_Public.Consignmentpassword " +
                ",GoodsTracked_Record_Top_Public.Arrivalcode " +
                ",GoodsTracked_Record_Top_Public.Arrivalpassword " +
                ",GoodsTracked_Record_Top_Public.TracePlatformId " +
                ",GoodsTracked_Record_Top_Public.ConsignmentLongitude " +
                ",GoodsTracked_Record_Top_Public.ConsignmentLatitude " +
                ",GoodsTracked_Record_Top_Public.ArrivalLongitude " +
                ",GoodsTracked_Record_Top_Public.ArrivalLatitude " +
                "from GoodsTracked_Record_Public  WITH(NOLOCK)  " +
                "left join GoodsTracked_Record_Top_Public   WITH(NOLOCK) " +
                "on GoodsTracked_Record_Public.ConsignmentBillMasterId=GoodsTracked_Record_Top_Public.ConsignmentBillMasterId " +
                " where GoodsTracked_Record_Public.Systime<='" + endTime + "'" +
                " and  GoodsTracked_Record_Public.Systime>='" + beginTime + "'" +
//                " and GoodsTracked_Record_Top_Public.organizationcode='fycsz'"+
                " and (GoodsTracked_Record_Public.UNIQUE_NO is null or GoodsTracked_Record_Public.UNIQUE_NO='')" +
                " and GoodsTracked_Record_Top_Public.TracePlatformId is not null"+
                " and GoodsTracked_Record_Top_Public.TracePlatformId !='失败' "+
                " and GoodsTracked_Record_Top_Public.TracePlatformId !='' ";
        if(organizationcode!=null&&organizationcode.length()!=0){
            sql=sql+  " and GoodsTracked_Record_Public.organizationcode='" + organizationcode + "'" ;
        }
        sql=sql+ " order by GoodsTracked_Record_Public.systime";
        //System.out.print(sql);
        log.info("selectByNotUpload_List sql:"+sql);
        return jdbcDao_GoodsTracked.queryListForSql(sql, GoodsPublic.class);
    }

    @Override
    public List<GoodsPublic> selectWxNotUpload_List(String organizationcode, String beginTime, String endTime) {

        String sql = "select GoodsTracked_Record_Top_Public.Headquartersname Headquartersname, GoodsTracked_Record_Top_Public.databasename databasename,  GoodsTracked_Record_Top_Public.WxPublicNumber, GoodsTracked_Record_Public.SYSTIME" +
                ",GoodsTracked_Record_Top_Public.headquarterphone headquarterphone"+
                ",GoodsTracked_Record_Public.TypeNum  " +
                ",GoodsTracked_Record_Public.TypeName" +
                ",GoodsTracked_Record_Public.Info " +
                ",GoodsTracked_Record_Public.CreateOperator " +
                ",GoodsTracked_Record_Public.UNIQUE_NO " +
                ",GoodsTracked_Record_Public.RecordID " +
                ",GoodsTracked_Record_Public.Longitude " +
                ",GoodsTracked_Record_Public.Latitude " +
                ",GoodsTracked_Record_Public.DriverCode " +
                ",GoodsTracked_Record_Public.DriverName " +
                ",GoodsTracked_Record_Public.CarLicense " +
                ",GoodsTracked_Record_Top_Public.OrganizationCode " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillMasterId " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillNumber " +
                ",GoodsTracked_Record_Top_Public.GoodsNumber " +
                ",GoodsTracked_Record_Top_Public.ManualNumber " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillDate " +
                ",GoodsTracked_Record_Top_Public.PlaceOfLoading " +
                ",GoodsTracked_Record_Top_Public.SendCompany " +
                ",GoodsTracked_Record_Top_Public.ReceiveCompany " +
                ",GoodsTracked_Record_Top_Public.UnloadPlace " +
                ",GoodsTracked_Record_Top_Public.ConsignorCompanyCode " +
                ",GoodsTracked_Record_Top_Public.ConsignorCompany " +
                ",GoodsTracked_Record_Top_Public.Consignor " +
                ",GoodsTracked_Record_Top_Public.ConsignorMobileTelephone " +
                ",GoodsTracked_Record_Top_Public.ConsignorTelephone " +
                ",GoodsTracked_Record_Top_Public.ConsignorAddress " +
                ",GoodsTracked_Record_Top_Public.ConsigneeCompanyCode " +
                ",GoodsTracked_Record_Top_Public.ConsigneeCompany " +
                ",GoodsTracked_Record_Top_Public.Consignee " +
                ",GoodsTracked_Record_Top_Public.ConsigneeMobileTelephone " +
                ",GoodsTracked_Record_Top_Public.ConsigneeTelephone " +
                ",GoodsTracked_Record_Top_Public.ConsigneeAddress " +
                ",GoodsTracked_Record_Top_Public.OneCardCode " +
                ",GoodsTracked_Record_Top_Public.BankName " +
                ",GoodsTracked_Record_Top_Public.AccountHolder " +
                ",GoodsTracked_Record_Top_Public.Account " +
                ",GoodsTracked_Record_Top_Public.PaymentMethod " +
                ",GoodsTracked_Record_Top_Public.GoodsPickupMethod " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillRemark " +
                ",GoodsTracked_Record_Top_Public.GoodsName " +
                ",GoodsTracked_Record_Top_Public.GoodsPack " +
                ",GoodsTracked_Record_Top_Public.ReceiptNumber " +
                ",GoodsTracked_Record_Top_Public.IsReceipt " +
                ",GoodsTracked_Record_Top_Public.ReceiptCount " +
                ",GoodsTracked_Record_Top_Public.ReceiptRemark " +
                ",GoodsTracked_Record_Top_Public.TotalNumberOfPackages " +
                ",GoodsTracked_Record_Top_Public.TotalWeight " +
                ",GoodsTracked_Record_Top_Public.TotalVolume " +
                ",GoodsTracked_Record_Top_Public.TotalTransportCost " +
                ",GoodsTracked_Record_Top_Public.CollectionGoodsValue " +
                ",GoodsTracked_Record_Top_Public.AdvanceGoodsValue " +
                ",GoodsTracked_Record_Top_Public.AdvanceTransportCost " +
                ",GoodsTracked_Record_Top_Public.DataType " +
                ",GoodsTracked_Record_Top_Public.Consignoridcard " +
                ",GoodsTracked_Record_Top_Public.Consigneeidcard " +
                ",GoodsTracked_Record_Top_Public.Headquarterscode " +
                ",GoodsTracked_Record_Top_Public.Headquarterspassword " +
                ",GoodsTracked_Record_Top_Public.Consignmentcode " +
                ",GoodsTracked_Record_Top_Public.Consignmentpassword " +
                ",GoodsTracked_Record_Top_Public.Arrivalcode " +
                ",GoodsTracked_Record_Top_Public.Arrivalpassword " +
                ",GoodsTracked_Record_Top_Public.TracePlatformId " +
                ",GoodsTracked_Record_Top_Public.ConsignmentLongitude " +
                ",GoodsTracked_Record_Top_Public.ConsignmentLatitude " +
                ",GoodsTracked_Record_Top_Public.ArrivalLongitude " +
                ",GoodsTracked_Record_Top_Public.ArrivalLatitude " +
                "from GoodsTracked_Record_Public  " +
                "left join GoodsTracked_Record_Top_Public   " +
                "on GoodsTracked_Record_Public.ConsignmentBillMasterId=GoodsTracked_Record_Top_Public.ConsignmentBillMasterId " +
                " where GoodsTracked_Record_Public.Systime<='" + endTime + "'" +
                " and  GoodsTracked_Record_Public.Systime>='" + beginTime + "'" +
                " and (GoodsTracked_Record_Public.WxFlag is null or GoodsTracked_Record_Public.WxFlag ='')" +
                " and( GoodsTracked_Record_Public.Typenum in('5','1','72') or GoodsTracked_Record_Public.typename in('现金','代收货款转账成功') )"+
                " and GoodsTracked_Record_Top_Public.OrganizationCode='"+organizationcode+"'"+
                " and GoodsTracked_Record_Top_Public.Databasename!='' "+
//                " and  (GoodsTracked_Record_Top_Public.WxPublicNumber is not null) " +
                " order by GoodsTracked_Record_Public.systime asc ";
        log.info("selectWxNotUpload_List sql:"+sql);
        return jdbcDao_GoodsTracked.queryListForSql(sql, GoodsPublic.class);
    }

    @Override
    public List<GoodsPublic> selectXcxNotUpload_List(String organizationcode, String beginTime, String endTime) {

        String sql = "select GoodsTracked_Record_Top_Public.databasename databasename, GoodsTracked_Record_Top_Public.WxPublicNumber, GoodsTracked_Record_Public.SYSTIME" +
                ",GoodsTracked_Record_Public.TypeNum  " +
                ",GoodsTracked_Record_Public.TypeName" +
                ",GoodsTracked_Record_Public.Info " +
                ",GoodsTracked_Record_Public.CreateOperator " +
                ",GoodsTracked_Record_Public.UNIQUE_NO " +
                ",GoodsTracked_Record_Public.RecordID " +
                ",GoodsTracked_Record_Public.Longitude " +
                ",GoodsTracked_Record_Public.Latitude " +
                ",GoodsTracked_Record_Public.DriverCode " +
                ",GoodsTracked_Record_Public.DriverName " +
                ",GoodsTracked_Record_Public.CarLicense " +
                ",GoodsTracked_Record_Top_Public.OrganizationCode " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillMasterId " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillNumber " +
                ",GoodsTracked_Record_Top_Public.GoodsNumber " +
                ",GoodsTracked_Record_Top_Public.ManualNumber " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillDate " +
                ",GoodsTracked_Record_Top_Public.PlaceOfLoading " +
                ",GoodsTracked_Record_Top_Public.SendCompany " +
                ",GoodsTracked_Record_Top_Public.ReceiveCompany " +
                ",GoodsTracked_Record_Top_Public.UnloadPlace " +
                ",GoodsTracked_Record_Top_Public.ConsignorCompanyCode " +
                ",GoodsTracked_Record_Top_Public.ConsignorCompany " +
                ",GoodsTracked_Record_Top_Public.Consignor " +
                ",GoodsTracked_Record_Top_Public.ConsignorMobileTelephone " +
                ",GoodsTracked_Record_Top_Public.ConsignorTelephone " +
                ",GoodsTracked_Record_Top_Public.ConsignorAddress " +
                ",GoodsTracked_Record_Top_Public.ConsigneeCompanyCode " +
                ",GoodsTracked_Record_Top_Public.ConsigneeCompany " +
                ",GoodsTracked_Record_Top_Public.Consignee " +
                ",GoodsTracked_Record_Top_Public.ConsigneeMobileTelephone " +
                ",GoodsTracked_Record_Top_Public.ConsigneeTelephone " +
                ",GoodsTracked_Record_Top_Public.ConsigneeAddress " +
                ",GoodsTracked_Record_Top_Public.OneCardCode " +
                ",GoodsTracked_Record_Top_Public.BankName " +
                ",GoodsTracked_Record_Top_Public.AccountHolder " +
                ",GoodsTracked_Record_Top_Public.Account " +
                ",GoodsTracked_Record_Top_Public.PaymentMethod " +
                ",GoodsTracked_Record_Top_Public.GoodsPickupMethod " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillRemark " +
                ",GoodsTracked_Record_Top_Public.GoodsName " +
                ",GoodsTracked_Record_Top_Public.GoodsPack " +
                ",GoodsTracked_Record_Top_Public.ReceiptNumber " +
                ",GoodsTracked_Record_Top_Public.IsReceipt " +
                ",GoodsTracked_Record_Top_Public.ReceiptCount " +
                ",GoodsTracked_Record_Top_Public.ReceiptRemark " +
                ",GoodsTracked_Record_Top_Public.TotalNumberOfPackages " +
                ",GoodsTracked_Record_Top_Public.TotalWeight " +
                ",GoodsTracked_Record_Top_Public.TotalVolume " +
                ",GoodsTracked_Record_Top_Public.TotalTransportCost " +
                ",GoodsTracked_Record_Top_Public.CollectionGoodsValue " +
                ",GoodsTracked_Record_Top_Public.AdvanceGoodsValue " +
                ",GoodsTracked_Record_Top_Public.AdvanceTransportCost " +
                ",GoodsTracked_Record_Top_Public.DataType " +
                ",GoodsTracked_Record_Top_Public.Consignoridcard " +
                ",GoodsTracked_Record_Top_Public.Consigneeidcard " +
                ",GoodsTracked_Record_Top_Public.Headquarterscode " +
                ",GoodsTracked_Record_Top_Public.Headquarterspassword " +
                ",GoodsTracked_Record_Top_Public.Consignmentcode " +
                ",GoodsTracked_Record_Top_Public.Consignmentpassword " +
                ",GoodsTracked_Record_Top_Public.Arrivalcode " +
                ",GoodsTracked_Record_Top_Public.Arrivalpassword " +
                ",GoodsTracked_Record_Top_Public.TracePlatformId " +
                ",GoodsTracked_Record_Top_Public.ConsignmentLongitude " +
                ",GoodsTracked_Record_Top_Public.ConsignmentLatitude " +
                ",GoodsTracked_Record_Top_Public.ArrivalLongitude " +
                ",GoodsTracked_Record_Top_Public.ArrivalLatitude " +
                "from GoodsTracked_Record_Public  WITH(NOLOCK) " +
                "left join GoodsTracked_Record_Top_Public   WITH(NOLOCK)  " +
                "on GoodsTracked_Record_Public.ConsignmentBillMasterId=GoodsTracked_Record_Top_Public.ConsignmentBillMasterId " +
                " where GoodsTracked_Record_Public.Systime<='" + endTime + "'" +
                " and  GoodsTracked_Record_Public.Systime>='" + beginTime + "'" +
                " and (GoodsTracked_Record_Public.XcxFlag is null or GoodsTracked_Record_Public.XcxFlag ='')" +
//                " and  (GoodsTracked_Record_Top_Public.XcxPublicNumber is not null) " +
                " and GoodsTracked_Record_Top_Public.OrganizationCode='"+organizationcode+"'"+
//                " and GoodsTracked_Record_Public.TypeName in('货运单','预受理单','付货','直发','银行','现金')"+
                " and GoodsTracked_Record_Public.TypeName in('货运单')"+
                " order by GoodsTracked_Record_Public.systime asc ";
        log.info("selectWxNotUpload_List sql:"+sql);
        return jdbcDao_GoodsTracked.queryListForSql(sql, GoodsPublic.class);
    }
    @Override
    public void updatePublicXcx(String ConsignmentBillNumber,String OrganizationCode,String id) {
        try {
            String sql ="update  GoodsTracked_Record_Public  " +
                    "set XcxFlag='1'"+ " where " +
                    " OrganizationCode='"+OrganizationCode+"' " +
                    " and ConsignmentBillMasterId='"+ConsignmentBillNumber+"'"+
                    " and RecordID='"+id+"'" ;
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updatePublicXcx error:",e);
        }

    }
    @Override
    public void updatePublicWx(String ConsignmentBillNumber,String OrganizationCode,String id) {
        try {
            String sql ="update  GoodsTracked_Record_Public  " +
                    "set WxFlag='1'"+ " where " +
                    " OrganizationCode='"+OrganizationCode+"' " +
                    " and ConsignmentBillMasterId='"+ConsignmentBillNumber+"'"+
                    " and RecordID='"+id+"'" ;
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updatePublicWx error:",e);
        }

    }
    @Override
    public void updatePublicWxMessage(String ConsignmentBillNumber,String OrganizationCode,String id,String message) {
        try {
            String sql ="update  GoodsTracked_Record_Public  " +
                    "set WxFlag='1',wxMessage='"+message+"'"+ " where " +
                    " OrganizationCode='"+OrganizationCode+"' " +
                    " and ConsignmentBillMasterId='"+ConsignmentBillNumber+"'"+
                    " and RecordID='"+id+"'" ;
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updatePublicWx error:",e);
        }

    }
    @Override
    public void updateCar(String trackingNo,String OrganizationCode,String id) {
        try {
            String sql ="update  TransportBillMaster_public  " +
                    "set uploadstate='1',trackingNo='" + trackingNo + "'"+ " where " +
                    " OrganizationCode='"+OrganizationCode+"' " +
                    " and TransportBillMasterId='"+id+"'";
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updateCar error:",e);
        }

    }
    @Override
    public void updateCollection(String trackingNo,String OrganizationCode,String id) {
        try {
            String sql ="update  CollectionGoodsValueAccount_Public  " +
                    "set flag='1',trackingNo='" + trackingNo + "'"+ " where " +
                    " OrganizationCode='"+OrganizationCode+"' " +
                    " and CollectionGoodsValueAccountId='"+id+"'";
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updateCollection error:",e);
        }

    }
    @Override
    public void updateCollectionsetId(String id) {
        try {
            String sql ="delete from CollectionGoodsValueAccount_Public " +
                    " where CollectionGoodsValueAccountId='"+id+"' ";
            sql +=" and flag='2' ";
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){
            log.error("updateCollectionsetId error:",e);
        }

    }
}
